/**
 * @param {number} n
 * @return {number}
*/
var arrangeCoins = function(n) {
  let line = 0;
  while(n >= line + 1) {
    line++;
    n -= line;
  }
  return line;
};
let n = 5;
console.log(arrangeCoins(n));
n = 8;
console.log(arrangeCoins(n));
